package currency;

public class Parser {

    // 国家
    private String country;
    // 数量
    private String _amout;
    // 
    private double amount;
    // 货币
    private CurrencyType destCurrencyType;
    
    public Parser(String country, String amout) {
        super();
        this.country = country;
        this._amout = amout;
    }

    /**
     * 解析国家
     * 
     * @return
     */
    public void parseContry() {
        if (null == country || country.isEmpty()) {
            throw new ParseException("国家解析错误");
        }
        
        destCurrencyType = Enum.valueOf(CurrencyType.class,country);
    }
    
    public void parseAmount() {
        if (null == _amout || _amout.isEmpty()) {
            throw new ParseException("金额解析错误");
        }
        amount = Double.valueOf(_amout);
    }
    
    public void parse() {
        parseContry();
        parseAmount();
    }
    public CurrencyType toCurrencyType() {
        return destCurrencyType;
    }
    
    public double amount() {
        return amount;
    }
}
